Skip to contentSkip to conversation

Change in openvpn[master]: Fix PASS_BY_VALUE issue in options_postprocess_mutate_le()

Openvpn-devel In review its_Giaan (Code Review) 2 participants 6 messages Jan 24, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1737722584000.I0542df021ae0ba9c982335fed7bbd10ed326dd0f@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/875?usp=email

to review the following change.

Change subject: Fix PASS_BY_VALUE issue in options_postprocess_mutate_le()
......................................................................

Fix PASS_BY_VALUE issue in options_postprocess_mutate_le()

Fix issue reported by Coverity:
CID 1641424: Performance inefficiencies (PASS_BY_VALUE)
Passing parameter ce of type "struct connection_entry" (size 208 bytes) by value, which exceeds the low threshold of 128 bytes.

Commit 8466c2ca unintentionally introduced a performance penalty due to passing struct connection_entry 'ce' by value to options_postprocess_mutate_le(). fix this by passing 'ce' by address.

Change-Id I0542df021ae0ba9c982335fed7bbd10ed326dd0f

---
M src/openvpn/options.c

1 file changed, 3 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/75/875/1

src/openvpn/options.c +3 -3
index c938999..bd5c056 100644
@@ -3323,12 +3323,12 @@
 }
 
 static void
-options_postprocess_mutate_le(struct connection_entry ce, struct local_entry *le)
+options_postprocess_mutate_le(struct connection_entry *ce, struct local_entry *le)
 {
     /* use the global port if none is specified */
     if (!le->port)
     {
-        le->port = ce.local_port;
+        le->port = ce->local_port;
     }
 }
 
@@ -3777,7 +3777,7 @@
     {
         for (i = 0; i < o->ce.local_list->len; i++)
         {
-            options_postprocess_mutate_le(o->ce, o->ce.local_list->array[i]);
+            options_postprocess_mutate_le(&o->ce, o->ce.local_list->array[i]);
         }
     }
     else

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/875?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0542df021ae0ba9c982335fed7bbd10ed326dd0f
Gerrit-Change-Number: 875
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, its_Giaan, plaisthos.

cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/875?usp=email )

Change subject: Fix PASS_BY_VALUE issue in options_postprocess_mutate_le()
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/875?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0542df021ae0ba9c982335fed7bbd10ed326dd0f
Gerrit-Change-Number: 875
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 24 Jan 2025 12:58:14 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

PATCH 1/1 Fix PASS_BY_VALUE issue in options_postprocess_mutate_le()

In reply to a message not in the archive

From: Gianmarco De Gregori <[email protected]...>

Fix issue reported by Coverity:
CID 1641424: Performance inefficiencies (PASS_BY_VALUE)
Passing parameter ce of type "struct connection_entry" (size 208 bytes) by value, which exceeds the low threshold of 128 bytes.

Commit 8466c2ca unintentionally introduced a performance penalty due to passing struct connection_entry 'ce' by value to options_postprocess_mutate_le(). fix this by passing 'ce' by address.

Change-Id I0542df021ae0ba9c982335fed7bbd10ed326dd0f

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/875
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/options.c +3 -3
index c938999..bd5c056 100644
@@ -3323,12 +3323,12 @@
 }
 
 static void
-options_postprocess_mutate_le(struct connection_entry ce, struct local_entry *le)
+options_postprocess_mutate_le(struct connection_entry *ce, struct local_entry *le)
 {
     /* use the global port if none is specified */
     if (!le->port)
     {
-        le->port = ce.local_port;
+        le->port = ce->local_port;
     }
 }
 
@@ -3777,7 +3777,7 @@
     {
         for (i = 0; i < o->ce.local_list->len; i++)
         {
-            options_postprocess_mutate_le(o->ce, o->ce.local_list->array[i]);
+            options_postprocess_mutate_le(&o->ce, o->ce.local_list->array[i]);
         }
     }
     else
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix PASS_BY_VALUE issue in options_postprocess_mutate_le()

So much of a commit message for such a small patch :-) - but of course it makes sense.

Your patch has been applied to the master branch.

commit 8a0f297e068b6701acceafc5af92eddd18a4151b

Author: Gianmarco De Gregori
Date:   Fri Jan 24 14:00:00 2025 +0100
     Fix PASS_BY_VALUE issue in options_postprocess_mutate_le()

     Signed-off-by: Gianmarco De Gregori <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg30566.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/875?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: Fix PASS_BY_VALUE issue in options_postprocess_mutate_le()
......................................................................

Fix PASS_BY_VALUE issue in options_postprocess_mutate_le()

Fix issue reported by Coverity:
CID 1641424: Performance inefficiencies (PASS_BY_VALUE)
Passing parameter ce of type "struct connection_entry" (size 208 bytes) by value, which exceeds the low threshold of 128 bytes.

Commit 8466c2ca unintentionally introduced a performance penalty due to passing struct connection_entry 'ce' by value to options_postprocess_mutate_le(). fix this by passing 'ce' by address.

Change-Id I0542df021ae0ba9c982335fed7bbd10ed326dd0f

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30566.html

---
M src/openvpn/options.c

1 file changed, 3 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/75/875/2

src/openvpn/options.c +3 -3
index c938999..bd5c056 100644
@@ -3323,12 +3323,12 @@
 }
 
 static void
-options_postprocess_mutate_le(struct connection_entry ce, struct local_entry *le)
+options_postprocess_mutate_le(struct connection_entry *ce, struct local_entry *le)
 {
     /* use the global port if none is specified */
     if (!le->port)
     {
-        le->port = ce.local_port;
+        le->port = ce->local_port;
     }
 }
 
@@ -3777,7 +3777,7 @@
     {
         for (i = 0; i < o->ce.local_list->len; i++)
         {
-            options_postprocess_mutate_le(o->ce, o->ce.local_list->array[i]);
+            options_postprocess_mutate_le(&o->ce, o->ce.local_list->array[i]);
         }
     }
     else

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/875?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0542df021ae0ba9c982335fed7bbd10ed326dd0f
Gerrit-Change-Number: 875
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/875?usp=email )

Change subject: Fix PASS_BY_VALUE issue in options_postprocess_mutate_le()
......................................................................

Fix PASS_BY_VALUE issue in options_postprocess_mutate_le()

Fix issue reported by Coverity:
CID 1641424: Performance inefficiencies (PASS_BY_VALUE)
Passing parameter ce of type "struct connection_entry" (size 208 bytes) by value, which exceeds the low threshold of 128 bytes.

Commit 8466c2ca unintentionally introduced a performance penalty due to passing struct connection_entry 'ce' by value to options_postprocess_mutate_le(). fix this by passing 'ce' by address.

Change-Id I0542df021ae0ba9c982335fed7bbd10ed326dd0f

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30566.html

---
M src/openvpn/options.c

1 file changed, 3 insertions(+), 3 deletions(-)
src/openvpn/options.c +3 -3
index c938999..bd5c056 100644
@@ -3323,12 +3323,12 @@
 }
 
 static void
-options_postprocess_mutate_le(struct connection_entry ce, struct local_entry *le)
+options_postprocess_mutate_le(struct connection_entry *ce, struct local_entry *le)
 {
     /* use the global port if none is specified */
     if (!le->port)
     {
-        le->port = ce.local_port;
+        le->port = ce->local_port;
     }
 }
 
@@ -3777,7 +3777,7 @@
     {
         for (i = 0; i < o->ce.local_list->len; i++)
         {
-            options_postprocess_mutate_le(o->ce, o->ce.local_list->array[i]);
+            options_postprocess_mutate_le(&o->ce, o->ce.local_list->array[i]);
         }
     }
     else

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/875?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0542df021ae0ba9c982335fed7bbd10ed326dd0f
Gerrit-Change-Number: 875
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged